package org.ihelpuoo.weboo.action.http.db;

import java.sql.Timestamp;

import org.ihelpuoo.orm.Entity;
import org.ihelpuoo.orm.filter.FieldFilter;
import org.ihelpuoo.weboo.module.ActionContext;

public class SaveEntityAction extends SaveAction
{

	@Override
	protected Object save(ActionContext context, Object obj, FieldFilter actived, FieldFilter locked)
			throws Exception
	{
		return super.save(context,setupEntity(context,(Entity)obj),actived,locked);
	}

	protected Entity setupEntity(ActionContext context, Entity ent) throws Exception
	{
		Timestamp now = new Timestamp(context.now().getTimeInMillis());
		if (context.pojo().isNewIsDB(ent))
			ent.setCreateTime(now);
		ent.setLastModifiedTime(now);
		return ent;
	}

}
